package com.mobileares.midp.widgets.client.frame;

import com.google.gwt.user.client.ui.*;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2011-3-16
 * Time: 16:22:36
 * To change this template use File | Settings | File Templates.
 */
public class Header extends Composite {
    private FlowPanel header = new FlowPanel();
    private Image logo;
    private Label welcome;
    private FlowPanel headContainer;
    private SimplePanel functionBar;

    public Header() {
        header.setStyleName("frame-header");
        initWidget(header);
        init();
    }

    private void setWelcomeWord(String word) {
        welcome.setText(word);
    }

    private void init() {
        logo = new Image("fishimages/logo.jpg");
        logo.setStyleName("image");
        logo.setHeight("35px");
        header.add(logo);
        initHeadContainer();
        header.add(headContainer);
        initFunctionBar();
        header.add(functionBar);

        SimplePanel clear = new SimplePanel();
        clear.setStyleName("clearfloat");
        header.add(clear);
    }

    public void setLogo(String path) {
        logo.setUrl(path);
    }

    public void setWelcomeText(String text) {
        welcome.setText(text);
    }

    public void addHeadWidget(Widget widget) {
        headContainer.add(widget);
    }

    public void setFunctionBarWidget(Widget widget) {
        functionBar.setWidget(widget);
    }

    private void initHeadContainer() {
        welcome = new Label("DEMO,欢迎使用!");
        welcome.setStyleName("welcome-text");
        FlowPanel first = new FlowPanel();
        first.add(welcome);
//        FlowPanel second = new FlowPanel();
//        TextAnchor index = new TextAnchor("首页");
//        TextAnchor setting = new TextAnchor("设置");
//        second.add(index);
//        second.add(new Split());
//        second.add(setting);

        headContainer = new FlowPanel();
        headContainer.setStyleName("welcome");
        first.setStyleName("div");
        headContainer.add(first);
//        headContainer.add(second);

    }

    private void initFunctionBar() {
        functionBar = new SimplePanel();
        functionBar.setStyleName("bar");
//        TextAnchor index = new TextAnchor("退出");
//        TextAnchor setting = new TextAnchor("登录");
//        functionBar.add(index);
//        functionBar.add(new Split());
//        functionBar.add(setting);
    }
}
